package client;

import client.ClientNavigator;



public abstract class Client {

	private ClientNavigator navigator;
	
	private String sessionId = java.util.UUID.randomUUID().toString();

	protected Client() {
	}

	public Client(ClientNavigator navigator) {
		this.navigator = navigator;
		if(navigator != null)
			navigator.setClient(this);
		//Logger.getLogger("Client").info("Client " + this.getClass() + " started");
	}

	public void doCommand(String name) {
		//Logger.getLogger("Client").info("doing command " + name);
		
		Command command = navigator.getCommand(name);
		if(command != null) {
			command.doFunction();
			gotResult(command);
		}
	}
	
	public abstract void exit();

	public abstract String getCommand();
	
	public ClientNavigator getNavigator() {
		return navigator;
	}

	public String getSessionId() {
		return sessionId;
	}
	
	public abstract void gotResult(Command command);


}
